package com.example.administrator.waitan.find.event;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.example.administrator.waitan.R;
import com.example.administrator.waitan.base.BaseActivity;
import com.example.administrator.waitan.find.FindFragment;
import com.example.administrator.waitan.tools.GsonRequest;
import com.example.administrator.waitan.tools.VolleySingleton;
import com.google.gson.Gson;

import java.util.ArrayList;
import java.util.List;

import cn.sharesdk.framework.ShareSDK;
import cn.sharesdk.onekeyshare.OnekeyShare;

/**
 * Created by Administrator on 2016/1/12.
 */
public class EventActivity extends BaseActivity {
    private RecyclerView mRecyclerView;
    private EventRecyclerViewAdapter mAdapter;
    private List<EventListData> eventListDatas;
    private RequestQueue queue;
    private String url = "http://s.budejie.com/topic/list/jingxuan/29/budejie-android-6.2.7/0-20.json?market=wandoujia&ver=6.2.7&visiting=&os=5.1&appname=baisibudejie&client=android&udid=000000000000000&mac=08%3A00%3A27%3A3f%3A7a%3A01";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_event);
        final EventProgressDialog dialog = new EventProgressDialog(this, "段子在路上...", R.anim.activity_in);
        dialog.show();
        mRecyclerView = (RecyclerView) findViewById(R.id.rc_event_rc);
        GsonRequest<EventBeans> eventBeansGsonRequest = new GsonRequest<EventBeans>(url, EventBeans.class, new Response.Listener<EventBeans>() {
            @Override
            public void onResponse(EventBeans response) {
                mAdapter = new EventRecyclerViewAdapter(EventActivity.this, response.getList());
                mRecyclerView.setLayoutManager(new LinearLayoutManager(EventActivity.this));
                mRecyclerView.setAdapter(mAdapter);
                dialog.dismiss();
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {

            }
        });
        VolleySingleton.getInstance()._addRequest(eventBeansGsonRequest);
        findViewById(R.id.btn_event_like).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showShare();
            }
        });
    }

    private void showShare() {
        ShareSDK.initSDK(this);
        OnekeyShare oks = new OnekeyShare();
        //关闭sso授权
        oks.disableSSOWhenAuthorize();

// 分享时Notification的图标和文字  2.5.9以后的版本不调用此方法
        //oks.setNotification(R.drawable.ic_launcher, getString(R.string.app_name));
        // title标题，印象笔记、邮箱、信息、微信、人人网和QQ空间使用
        oks.setTitle("来吧");
        // titleUrl是标题的网络链接，仅在人人网和QQ空间使用
        oks.setTitleUrl("http://sharesdk.cn");
        // text是分享文本，所有平台都需要这个字段
        oks.setText("我是分享文本");
        // imagePath是图片的本地路径，Linked-In以外的平台都支持此参数
//        oks.setImagePath("/sdcard/test.jpg");//确保SDcard下面存在此张图片
//        // url仅在微信（包括好友和朋友圈）中使用
        oks.setUrl("http://sharesdk.cn");
        // comment是我对这条分享的评论，仅在人人网和QQ空间使用
        oks.setComment("我是测试评论文本");
        // site是分享此内容的网站名称，仅在QQ空间使用
        oks.setSite(getString(R.string.app_name));
        // siteUrl是分享此内容的网站地址，仅在QQ空间使用
        oks.setSiteUrl("http://sharesdk.cn");

// 启动分享GUI
        oks.show(this);
    }

}


